
                    <div class="row clearfix">
                        <!--左边栏-->
                        <div class="col-md-8 column">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    写博客
                                </div>
                                <div class="panel-body">
                                    <div>
                                        <label class="sr-only" for="blogTitle">名称</label>
                                        <input type="text" class="form-control" id="blogTitle" placeholder="标题">
                                    </div>
                                    <div style="margin-bottom: 1em; margin-top: 1em">
                                        <label for="blogContent" class="sr-only">博客内容</label>
                                        <textarea class="form-control" rows="13" id="blogContent"></textarea>
                                    </div>
                                    <div>
                                        <button type="button" class="btn btn-default btn-md" id="saveDraft" >
                                            <span class="glyphicon glyphicon-floppy-disk"></span>
                                            保存草稿
                                        </button>
                                        <button type="button" class="btn btn-primary btn-md " id="submit" >
                                            <span class="glyphicon glyphicon-send"></span>
                                            发布博客
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--右边栏-->
                        <div class="col-md-4 column visible-lg visible-md">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    最近文章
                                </div>
                                <div class="panel-body">
                                    <ul>
                                        <?php foreach ($recentBlogList as $blogItem): ?>
                                            <li>
                                                <a href="<?php echo site_url() . '/OceanBlog/MainPage/view?id=' . $blogItem['id'];?>"><?php echo $blogItem['create_dt'] . " " . $blogItem['title']; ?></a> 
                                            </li>
                                        <?php endforeach; ?>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!--模态框（Modal）--> 
        <div class="modal fade" id="messageBox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="msgbox-type"></h4>
                    </div>
                    <div class="modal-body" id="msgbox-message"></div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
                    </div>
                </div> 
            </div> 
        </div>


        <script>
            $('#submit').on('click', function () {
                var title = $('#blogTitle').val();
                var content = $('#blogContent').val();
                if (title == '' || content == '') {
                    //如果为空则显示alert

                } else {
                    $.ajax({
                        url: '<?php echo site_url() . '/OceanBlog/MainPage/insertBlog'; ?>',
                        type: "post",
                        dataType: 'json',
                        data: {
                            title: title,
                            content: content
                        },
                        success: function () {
                            showDialog(0, '文章发布成功');
                        },
                        error: function (err) {
                            showDialog(1, err.responseJSON.msg);
                            console.log(err.responseJSON.msg);
                        }
                    });
                }

            });

            function showDialog(level, message) {
                var title = '';
                switch (level) {
                    case 0:
                        title = '<p class="text-info">消息</p>';
                        break;
                    case 1:
                        title = '<p class="text-danger">错误</p>';
                        break;
                    default:
                        title = '消息框';

                }
                $('#msgbox-type').html(title);
                $('#msgbox-message').html(message);
                $('#messageBox').modal('show');
            }
        </script>
